home *** CD-ROM | disk | FTP | other *** search
- /* cat > headers/help.h << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* help.h: header for help.c file */
- /* Create help windows. Within the help window, */
- /* user can read help files by selecting */
- /* through the menu and report bugs using */
- /* 'bug report'. */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- #define help_h 1
-
- #include "all.h"
- #include "newext.h"
-
- static Panel_item patn_item, msg_item, deliver_button;
-
- static Textsw_index first;
-
- static char *bugf;
-
- static void bug_deliver();
- static void help_done();
- static int msgwrite();
- static void pattern_search();
- static void reset_text();
- static Panel_setting search_proc();
-
-
- /* EOF */
- /* cat > src+obj/help/bug_deliver.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* bug_deliver: (static) deliver bug */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- static void
- bug_deliver ()
- {
-
- /* Implementation note(s):
- 1. The mail command is assumed to be executed in the C-Shell.
- */
-
- Textsw_index start, end, newstart, newend, next_pos;
- int next_newline, msg_length;
- char *p_defaultstr;
-
- static int startup = 1;
- static char bug_email[MAXNAMELEN] = DEFAULT_BUG_EMAIL_ADDRESS;
-
- if (startup)
- { /* try to get E-mail address from defaults */
- startup = 0;
- if ((p_defaultstr = get_defaults (BUG_EMAIL_ADDRESS)) == NULL)
- {
- sprintf (wkstr, "Warning: No defaults bug E-Mail address - %s used.", bug_email);
- msg_write (wkstr);
- }
- else
- strcpy (bug_email, p_defaultstr);
- }
- sprintf (wkstr, "mail -s 'ImageTool 1.1 Bug Report' %s << EOF\r", bug_email);
- tty_write (wkstr);
-
- /* loop through the lines */
- newstart = start = 0;
- if ((end = (Textsw_index) window_get (textsw, TEXTSW_LENGTH)) == 0)
- { /* no message */
- tty_write ("EOF\r");
- return;
- }
- end = end - 1;
- while ((next_newline = textsw_find_bytes (textsw, &newstart, &newend, "\n", 0)) != -1)
- {
- msg_length = ((newstart - start) > MAXNAMELEN) ? MAXNAMELEN - 1 : (newstart - start) + 1;
- if ((newstart - start) > MAXNAMELEN) /* name too long - putout message and line will be truncated */
- {
- sprintf (wkstr, "Warning: Line of bug message truncated to %d characters.", MAXNAMELEN - 1);
- msg_write (wkstr);
- }
- next_pos = (Textsw_index) window_get (textsw, TEXTSW_CONTENTS, start, msgstr, msg_length);
- if (next_pos != start + msg_length)
- {
- msg_write ("Internal error: Could not copy line from textsubwindow to buffer. Skipped.");
- }
- else
- {
- tty_write (" "); /* push over the line by a space to be sure that it doesn't start with an EOF */
- msgstr[msg_length + 1] = '\0';
- tty_write (msgstr);
- }
- if (newstart == end) /* done */
- break;
- else
- start = newstart += 1;
- }
- if (newstart != end) /* last line does not end in a newline */
- {
- msg_length = ((end - start) > MAXNAMELEN) ? MAXNAMELEN - 1 : (end - start) + 1;
- if ((end - start) > MAXNAMELEN) /* name too long - putout message and line will be truncated */
- {
- sprintf (wkstr, "Warning: Line of bug message truncated to %d characters.", MAXNAMELEN - 1);
- msg_write (wkstr);
- }
- next_pos = (Textsw_index) window_get (textsw, TEXTSW_CONTENTS, start, msgstr, msg_length);
- if (next_pos != start + msg_length)
- {
- msg_write ("Internal error: Could not copy line from textsubwindow to buffer. Skipped.");
- }
- else
- {
- tty_write (" "); /* push over the line by a space to be sure that it doesn't start with an EOF */
- msgstr[msg_length + 1] = '\0';
- tty_write (msgstr);
- tty_write ("\n");
- }
- }
- tty_write ("EOF\r");
- return;
- }
- /* EOF */
- /* cat > src+obj/help/bug_report.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* bug_report: bug_report let user write */
- /* comments/questions/problems in text */
- /* window and press on 'deliver' button to */
- /* send */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- bug_report ()
- {
- window_set (textsw,
- TEXTSW_READ_ONLY, FALSE, /* writeable */
- 0);
- window_set (help_window,
- FRAME_LABEL, "Bug report --- Imagetool 1.1",
- WIN_SHOW, TRUE,
- 0);
- panel_set (deliver_button, PANEL_SHOW_ITEM, TRUE, 0);
- textsw_reset (textsw, 0, 0);
- msgwrite ("Please compose message in text window below . . .");
- }
- /* EOF */
- /* cat > src+obj/help/create_help_menu.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* create_help_menu: create menu items under 'HELP' */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- create_help_menu ()
- {
-
- help_menu = menu_create (MENU_FONT, font_menu,
- MENU_STRINGS, "Basics",
- "Menus",
- "Button usages",
- "Examples",
- /* "Error info", */
- "Bug report",
- 0,
- MENU_NOTIFY_PROC, help_proc,
- 0);
- }
- /* EOF */
- /* cat > src+obj/help/create_helpsw.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* create_helpsw: build help window and buttons */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- create_helpsw ()
- {
- Panel panel;
- Rect *canvas_rect, *panel_rect;
- Pixfont *pfont, *tfont;
- int x_offset = 100;
- int y_offset = 25;
- int button_offset;
-
- /* location of the help_window: put it in the canvas
- region offset a little so that everything is
- visible. */
-
- canvas_rect = (Rect *) window_get (canvas, WIN_RECT);
-
- help_window = window_create (base, FRAME,
- FRAME_SHOW_LABEL, TRUE,
- FRAME_LABEL, "Help_window, ImageTool",
- WIN_X, (canvas_rect->r_left + x_offset),
- WIN_Y, (canvas_rect->r_top + y_offset),
- 0);
- panel = window_create (help_window, PANEL,
- WIN_FONT, font_panel,
- WIN_HEIGHT, 60,
- 0);
-
- textsw = window_create (help_window, TEXTSW,
- WIN_BELOW, panel,
- WIN_X, 0,
- WIN_HEIGHT, 400,
- 0);
-
- pfont = (Pixfont *) window_get (panel, WIN_FONT);
- tfont = (Pixfont *) window_get (textsw, WIN_FONT);
- if (pfont->pf_defaultsize.x > tfont->pf_defaultsize.x)
- /* panel font larger */
- window_set (panel, WIN_COLUMNS, 80, 0);
- else
- window_set (textsw, WIN_COLUMNS, 80, 0);
-
- patn_item = panel_create_item (panel, PANEL_TEXT,
- PANEL_ITEM_X, 10,
- PANEL_ITEM_Y, 10,
- PANEL_LABEL_STRING, "Search Pattern:",
- PANEL_VALUE_STORED_LENGTH, MAXNAMELEN - 1,
- PANEL_VALUE_DISPLAY_LENGTH, 30,
- PANEL_LABEL_BOLD, TRUE,
- PANEL_MENU_TITLE_STRING, "Help search",
- PANEL_MENU_CHOICE_STRINGS, "Return - Search pattern", 0,
- PANEL_MENU_CHOICE_FONTS, font_menu, 0,
- PANEL_MENU_CHOICE_VALUES, CR, 0,
- PANEL_SHOW_MENU, TRUE,
- PANEL_NOTIFY_LEVEL, PANEL_ALL,
- PANEL_NOTIFY_PROC, search_proc,
- 0);
- msg_item = panel_create_item (panel, PANEL_MESSAGE,
- PANEL_ITEM_X, 30,
- PANEL_ITEM_Y, 30,
- 0);
-
- button_offset = (strlen ("Search Pattern:") + 30 + 4) * font_panel->pf_defaultsize.x;
- deliver_button = panel_create_item (panel, PANEL_BUTTON,
- PANEL_ITEM_X, button_offset,
- PANEL_ITEM_Y, 10,
- PANEL_LABEL_IMAGE, panel_button_image (panel, "Deliver", 7, font_panel_button),
- PANEL_FEEDBACK, PANEL_INVERTED,
- PANEL_SHOW_ITEM, FALSE,
- PANEL_NOTIFY_PROC, bug_deliver,
- 0);
-
- button_offset += (strlen ("Deliver") + 2) * font_panel_button->pf_defaultsize.x;
- panel_create_item (panel, PANEL_BUTTON,
- PANEL_ITEM_X, button_offset,
- PANEL_ITEM_Y, 10,
- PANEL_LABEL_IMAGE, panel_button_image (panel, "Top", 6, font_panel_button),
- PANEL_FEEDBACK, PANEL_INVERTED,
- PANEL_NOTIFY_PROC, reset_text,
- 0);
-
- button_offset += (strlen ("Deliver") + 1) * font_panel_button->pf_defaultsize.x;
- panel_create_item (panel, PANEL_BUTTON,
- PANEL_ITEM_X, button_offset,
- PANEL_ITEM_Y, 10,
- PANEL_LABEL_IMAGE, panel_button_image (panel, "Done", 6, font_panel_button),
- PANEL_FEEDBACK, PANEL_INVERTED,
- PANEL_NOTIFY_PROC, help_done,
- 0);
- window_fit (help_window);
-
- /* set color map same with imagetool */
- (void) color_help_win ();
- }
- /* EOF */
- /* cat > src+obj/help/help_done.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* help_done: (static) done with help */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- static void
- help_done ()
- {
- window_set (help_window, WIN_SHOW, FALSE, 0);
- if (panel_get (deliver_button, PANEL_SHOW_ITEM, 0))
- panel_set (deliver_button, PANEL_SHOW_ITEM, FALSE, 0);
- }
- /* EOF */
- /* cat > src+obj/help/help_handler.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* help_handler: handler to display menu when 'HELP' */
- /* is selected */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- help_handler (item, event)
- Panel_item item;
- Event *event;
- {
- if (display_panel_menu (item, event, menu_panel, help_menu))
- help_proc (help_menu, menu_get (help_menu, MENU_NTH_ITEM, 1));
- }
- /* EOF */
- /* cat > src+obj/help/help_proc.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* help_proc: handler called when a menu item is */
- /* selected */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- void
- help_proc (m, mi)
- Menu m;
- Menu_item mi;
- {
- char str[MAXNAMELEN];
- char fn[MAXNAMELEN];
-
- fn[0] = '\0';
-
- /* get menu string name */
- strcpy (str, (char *) menu_get (mi, MENU_STRING));
-
- /* initialize the search position for patterns */
- first = 0;
-
- /* for mailing bugs */
- if (!strcmp ("Bug report", str))
- {
- bug_report ();
- return;
- }
-
- if (panel_get (deliver_button, PANEL_SHOW_ITEM, 0))
- panel_set (deliver_button, PANEL_SHOW_ITEM, FALSE, 0);
-
- if (!strcmp ("Menus", str))
- sprintf (fn, "%s/imagetool_menus", help_dir);
- else if (!strcmp ("Basics", str))
- sprintf (fn, "%s/imagetool_basics", help_dir);
- else if (!strcmp ("Button usages", str))
- sprintf (fn, "%s/imagetool_buttons", help_dir);
- else if (!strcmp ("Examples", str))
- sprintf (fn, "%s/imagetool_examples", help_dir);
- /* else if (!strcmp ("Error info", str))
- sprintf (fn, "%s/imagetool_errors", help_dir); */
-
- read_help_file (fn);
- }
- /* EOF */
- /* cat > src+obj/help/msgwrite.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* msgwrite: (static) write message */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- static int
- msgwrite (msg)
- char *msg;
- {
- panel_set (msg_item, PANEL_LABEL_STRING, msg, 0);
- }
- /* EOF */
- /* cat > src+obj/help/pattern_search.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* pattern_search: (static) pattern search */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- static void
- pattern_search (item)
- Panel_item item;
- {
- /* Implementation note(s):
- 1. If first is beyond the end of text, textsw_find_bytes, will
- wrap to the beginning in the search. Last is only returned.
- */
- char str[MAXNAMELEN];
- Textsw_index last;
- int len;
-
- strcpy (str, (char *) panel_get_value (item));
- len = strlen (str);
- if (len > 0)
- {
- if (textsw_find_bytes (textsw, &first, &last, str, len, 0) > 0)
- {
- msgwrite (""); /* message cleared */
- textsw_set_selection (textsw, first, last, 1);
- textsw_possibly_normalize (textsw, first);
- first++;
- }
- else
- msgwrite ("Pattern not found");
- }
- }
- /* EOF */
- /* cat > src+obj/help/read_help_file.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* read_help_file: display a help file in a text window */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- read_help_file (fn)
- char *fn;
- {
- Textsw_status status;
- int len;
-
- len = strlen (fn);
-
- msgwrite ("");
- window_set (textsw,
- TEXTSW_FILE, fn, /* load file */
- TEXTSW_STATUS, &status,
- 0);
- if (status == TEXTSW_STATUS_OKAY)
- { /* loading succeeded */
- reset_text (); /* start at top of file */
- window_set (textsw,
- TEXTSW_READ_ONLY, TRUE, /* read only */
- 0);
- window_set (help_window,
- FRAME_LABEL, fn,
- WIN_SHOW, TRUE,
- 0);
- }
- else
- {
- sprintf (wkstr, "Error: Help file is bad or does not exist.\n File = %s", fn);
- msg_write (wkstr);
- }
- return;
- }
- /* EOF */
- /* cat > src+obj/help/reset_text.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* reset_text: (static) reset text */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- static void
- reset_text ()
- {
- window_set (textsw, TEXTSW_FIRST, 1, 0);
- first = 0;
- }
- /* EOF */
- /* cat > src+obj/help/search_proc.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* search_proc: (static) search procedure */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "help.h" */
-
- static Panel_setting
- search_proc (item, event)
- Panel_item item;
- Event *event;
- {
- switch (event_id (event))
- {
- case CR:
- pattern_search (item);
- break;
- default:
- return panel_text_notify (item, event);
- }
- }
- /* EOF */
-